package com.leetcode.LC;

public class LC643 {
    public double findMaxAverage(int[] nums, int k) {
        if (nums.length==1){
            return nums[0];
        }

        int max=Integer.MIN_VALUE,sum;
        for (int i = 0; i < nums.length-k+1; i++) {
            sum=0;
            for (int j = 0; j < k; j++) {
                sum+=nums[i+j];
            }
            max=Math.max(sum,max);
        }

        return (double) max/k;

    }

    public static void main(String[] args) {
        System.out.println(new LC643().findMaxAverage(new int[]{1, 12, -5, -6, 50, 3}, 4));
    }
}
